<template>
  <div class="shop">
    <div class="nearby__item">
      <div class="nearby__left">
        <img class="nearby__left__img" :src="item.imgUrl" />
      </div>
      <div
        :class="{
          nearby__right: true,
          'nearby__right--bordered': hideBorder ? false : true,
        }"
      >
        <div class="nearby__right__title">{{ item.name }}</div>
        <div class="nearby__right__tags">
          <span class="nearby__right__tag">月销{{ item.sales }}+</span>
          <span class="nearby__right__tag">配送费${{ item.expressLimit }}</span>
          <span class="nearby__right__tag"
            >基础运费${{ item.expressPrice }}</span
          >
        </div>
        <div class="nearby__right__coupon">
          {{ item.slogan }}
        </div>
      </div>
    </div>

    <div class="productList" v-if="item.products">
      <template
        v-for="(product_item, product_index) in item.products"
        :key="product_index"
      >
        <div class="item">
          <div>
            <img class="item__img" :src="product_item.imgUrl" alt="" />
          </div>
          <div class="item__desc">
            <div class="name">{{ product_item.name }}</div>
            <div class="price">
              <span class="newPrice">&yen;{{ product_item.price }}</span>
              <span class="oldPrice">&yen;{{ product_item.oldPrice }}</span>
            </div>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
export default {
  name: "shopItems",
  props: ["item", "hideBorder"],
  setup() {
    return {};
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";
@import "@/styles/mixin.scss";

.shop {
  margin-bottom: 0.12rem;
  overflow: hidden;
}

.nearby__item {
  display: flex;
  justify-content: start;
  align-items: start;
  .nearby__left {
    margin-right: 0.16rem;
    &__img {
      width: 0.56rem;
      height: 0.56rem;
    }
  }
  .nearby__right {
    width: 100%;
    height: 0.86rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    &--bordered {
      border-bottom: 1px solid $bgc-color;
    }

    &__title {
      font-size: 0.16rem;
      color: $content-color;
      margin-bottom: 0.08rem;
    }
    &__tags {
      font-size: 0.13rem;
      color: $content-color;
      margin-bottom: 0.08rem;
      .nearby__right__tag {
        margin-right: 0.16rem;
      }
    }
    &__coupon {
      font-size: 0.13rem;
      color: #e93b3b;
      margin-bottom: 0.12rem;
    }
  }
}

.productList {
  box-sizing: border-box;
  // width: 2.4rem;
  margin-left: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: solid 1px $grey-color;
  .item {
    width: 0.76rem;
    &__img {
      width: 0.76rem;
      height: 0.76rem;
    }
    &__desc {
      margin-bottom: 0.12rem;
      font-size: 0.12rem;
      color: $content-color;
      .name {
        font-size: 0.12rem;
        color: #333333;
        @include textEli;
        line-height: 0.2rem;
      }
      .price {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        line-height: 0.16rem;
        .newPrice {
          font-size: 0.12rem;
          color: $highlight-color;
        }
        .oldPrice {
          font-size: 0.1rem;
          color: #999999;
          text-decoration: line-through;
        }
      }
    }
  }
}
</style>
